/*
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#include "quakedef.h"
#include "menu.shared.h"


class qmenu_options_t : public qmenu_t
{
public:
	qmenu_options_t (void)
	{
		// add our options to the menu
		this->AddOption (new qmenu_banner_t ("gfx/p_option.lmp"));
		this->AddOption (new qmenu_divider_t ());

		this->AddOption (new qmenu_submenu_t ("Customize controls", m_keys));
		this->AddOption (new qmenu_action_t ("Go to console", Con_ToggleConsole_f));
		this->AddOption (new qmenu_action_t ("Save configuration", Host_WriteConfiguration));
		this->AddOption (new qmenu_action_t ("Reset to defaults", Cmd_ResetAll_f));
		this->AddOption (new qmenu_divider_t ());

		this->AddOption (new qmenu_slider_t ("Brightness", "gamma", 0.5f, 1.0f, -0.025f));
		this->AddOption (new qmenu_slider_t ("Mouse speed", "sensitivity", 1.0f, 20.0f, 1.0f));
		this->AddOption (new qmenu_slider_t ("Music volume", "bgmvolume", 0.0f, 1.0f, 0.05f));
		this->AddOption (new qmenu_slider_t ("Sound volume", "volume", 0.0f, 1.0f, 0.05f));
		this->AddOption (new qmenu_divider_t ());

		this->AddOption (new qmenu_checkbox_t ("Always run", this->alwaysrun_watcher));
		this->AddOption (new qmenu_checkbox_t ("Invert mouse", this->invertmouse_watcher));
		this->AddOption (new qmenu_divider_t ());

		this->AddOption (new qmenu_submenu_t ("Video Options", m_video));

		// and register the menu
		this->Register (m_options);
	}

	void EnterFunc (void)
	{
		// and enter the menu
		this->EnterMenu ();
	}

private:
	class qmenu_alwaysrun_watcher_t : public qmenu_checkboxwatcher_t
	{
	public:
		BOOL GetFunc (void)
		{
			return cl_forwardspeed->value > 200;
		}

		void SetFunc (void)
		{
			Cvar_SetValue (cl_forwardspeed, (cl_forwardspeed->value > 200) ? 200 : 400);
			Cvar_SetValue (cl_backspeed, (cl_forwardspeed->value > 200) ? 200 : 400);
		}
	} alwaysrun_watcher;

	class qmenu_invertmouse_watcher_t : public qmenu_checkboxwatcher_t
	{
	public:
		BOOL GetFunc (void)
		{
			return m_pitch->value < 0;
		}

		void SetFunc (void)
		{
			Cvar_SetValue (m_pitch, -m_pitch->value);
		}
	} invertmouse_watcher;
} menu_options;


